import { useState, useEffect, useMemo } from "react";
import { View, Text } from "@tarojs/components";
import Card from "../component/card";
import Empty from "../component/empty";
import Taro, { useTabItemTap } from "@tarojs/taro";
import LgSelepicker from "@/pages/components/selePick";
import { getStorage } from "@/pages/components/utils/index";
import LgRefreshPage from "@/pages/components/refreshPage";
import LgSearch from "@/pages/components/searchInput";
import { LgPopLayer } from "@/pages/components/popLayerDefault";
import LgButton from "@/pages/components/button";
import { connect, useDispatch } from "react-redux";
import { HttpGet, HttpPost, HttpPut } from "@/network/servers";
import Utils from "@/utils/index";
import _ from "lodash";
import { getBrowserController } from "@/pages/components/utils";
import proxy from "@/network/proxy";
import { Modal, Popup, TextArea } from "antd-mobile";
import md5 from "md5";
import LgCheckbox from "@/pages/components/checkbox";
import { useTransformUrl } from "@/utils/myUtils";
import Loading from "@/pages/messageApp/component/load";
import useRedirectNotice from "../../../hooks/useRedirectNotice";
import "./index.scss";

const storage = getStorage();
const { getNowToken, recentDateStr } = Utils;

var wx = require("weixin-js-sdk");

const browserController = getBrowserController();

function App(props) {
  const {
    userInfo,
    env,
    termInfo,
    officeAddr,
    lg_ic,
    isEdu,
    baseUrl,
    mainServer,
    noticeAddr,
  } = props;

  const dispatch = useDispatch();
  const [allCount, setAllCount] = useState(0); //总数
  const [pullCount, setPullCount] = useState(1);
  const [todoList, setTodoList] = useState<any>([]);
  const [totalPage, setTotalPage] = useState(0);
  const [loadVisible, setLoadVisible] = useState(true);
  const [isOpen, setIsOpen] = useState(false); //日程
  const [isOpen2, setIsOpen2] = useState(false); //任务
  const [isOpen3, setIsOpen3] = useState(false); //自定义
  const [keyword, setKeyword] = useState("");
  const [infoObj, setinfoObj] = useState<any>({});
  const [assignmentObj, setAssignmentObj] = useState<any>({});
  const [currentTodo, setCurrentTodo] = useState<any>({});

  const [customPopupParams, setCustomPopupParams] = useState<any>({
    attrList: [],
    infoSource: {},
    optionList: [],
  });

  const [refuseReason, setRefuseReason] = useState("");
  const [isNoticePublisher, setIsNoticePublisher] = useState(1);
  const [showReasonBox, setShowReasonBox] = useState(false);

  const [statusList, setStatusList] = useState([
    {
      key: "",
      name: "全部状态",
    },
    {
      key: "0",
      name: "进行中",
    },
    {
      key: "1",
      name: "已完成",
    },
    {
      key: "2",
      name: "已逾期",
    },
  ]);
  const [typeList, setTypeList] = useState([]);
  const [currentStatus, setCurrentStatus] = useState("");
  const [currentType, setCurrentType] = useState("");
  const [isSearch, setIsSearch] = useState(false); //是否展示搜索框

  const getToken = () => {
    if (Utils.getQueryVariable("env") === "weapp") {
      return Utils.getQueryVariable("lg_tk");
    } else {
      return storage.get("token") || Utils.getQueryVariable("lg_tk");
    }
  };

  const getShowThisMsg = (item) => {
    //获取当前待办在此环境是否展示
    if (Utils.getSystemInfo() === "weapp") {
      //小程序环境
      switch (String(item.receiverType)) {
        case "0":
        case "3":
        case "5":
        case "6":
          return true;
        default:
          return false;
      }
    } else {
      switch (String(item.receiverType)) {
        case "0":
        case "2":
        case "4":
        case "6":
          return true;
        default:
          return false;
      }
    }
  };

  const getBasicInfo = () => {
    Taro.showLoading();
    HttpGet({
      url: "/api/message/type/list",
      data: {
        userId: userInfo.UserID,
        userType: userInfo.UserType,
        schoolId: userInfo.SchoolID,
        type: "2",
        environment: isEdu ? 1 : 2,
      },
      load: true,
    }).then((result) => {
      let typeList = result.data.messageSourceList;
      typeList.unshift({
        msgSourceId: "",
        msgSourceName: "全部类型",
      });
      setTypeList(typeList);
    });
  };

  // 获取todo列表
  const getTodoList = (n = 1) => {
    Taro.showLoading({ title: "加载中..." });
    // 获取待办事项总数
    HttpGet({
      url: `/api/todo/list/getPageList`,
      data: {
        pageIndex: 1,
        pageSize: 10 * n,
        status: currentStatus,
        keyWord: keyword,
        userId: userInfo.UserID,
        schoolId: userInfo.SchoolID,
        userType: userInfo.UserType,
        msgSourceId: currentType,
      },
      load: true,
    }).then((result) => {
      const info = result.data;

      let arr = [] as any;
      info &&
        info.forEach((item) => {
          arr.push({
            title: item.msgSourceName,
            content: item.msgPushContent,
            startTime: item.msgPushTime,
            endTime: item.msgPushExpire,
            ...item,
          });
        });

      setTodoList(arr);
      setAllCount(arr.length);
      setTotalPage(Math.ceil(Number(result.total) / 10));
      setLoadVisible(false);
    });
  };

  const jumpWeapp = (appId, path) => {
    try {
      browserController.navigateToMiniProgramForWebview(wx, {
        appId, //必传 跳转小程序唯一标识
        path, //必传 跳转后初始页面路径
        extraData: {},
        envVersion: "release", //必传 跳转小程序的版本
      });
    } catch (err) {
      Taro.showToast({ title: err, icon: "none" });
    }
  };

  const showMeSchedule = (item) => {
    if (item.status === "1") {
      //已完成的直接删除
      return;
    }
    HttpGet({
      url: officeAddr + "/api/schedule/info/detail",
      data: {
        userId: userInfo.UserID,
        userType: 0,
        schoolId: userInfo.SchoolID,
        scheduleId: item.msgId,
      },
      load: true,
    }).then((result) => {
      let infoObj = result.data;
      infoObj.todoMsgId = item.todoMsgId;
      setinfoObj(infoObj);
      HttpPost({
        url: officeAddr + "/api/schedule/member/update/attend",
        data: {
          userId: userInfo.UserID,
          scheduleId: item.msgId,
          attendFlag: 1,
          schoolId: userInfo.SchoolID,
        },
      });
      setIsOpen(true);
    });
  };

  const showMeAssignment = (todo) => {
    let msgId = todo.msgId.slice(0, 19);
    // mainServer + "edu-office-platform
    if (todo.status == 0) {
      HttpPut({
        //已读该任务
        url: mainServer + "edu-office-platform/api/task/user/read",
        data: {
          userId: userInfo.UserID,
          taskId: msgId,
        },
      });
    }

    HttpGet({
      url: mainServer + "edu-office-platform/api/task/info/detail",
      data: {
        userId: userInfo.UserID,
        taskId: msgId,
      },
    }).then((result) => {
      let assignmentInfo = result.data;
      setAssignmentObj(assignmentInfo);
      setIsOpen2(true);
    });
  };

  /**
   * @param {Array}  attrList 属性列表 [title,contentTitles...]
   * @param {Object}  infoSource  数据源
   * @param {Array}  optionList 操作项 [{text:'',callback:()=>{}}]
   * @returns
   */
  const customPopup = useMemo(() => {
    const { attrList, infoSource, optionList, todoInfo } = customPopupParams;
    console.log(infoSource)
    return (
      <View className="custom_pop">
        <View className="source_name">{attrList[0]}</View>
        <View className="custom_title">
          <Text className="text">{attrList[1]}</Text>
        </View>
        <View className="content_box">
          {Array.isArray(attrList) &&
            attrList.length > 2 &&
            attrList.map((item, index) => {
              if (index > 1) {
                if (item.key === "userName") {
                  return (
                    <View className="custom_row" key={item.key}>
                      <View className="left">{item.title || "--"}</View>
                      <View className="right">
                        <Text>{infoSource?.userName || "--"}</Text>
                        <Text style={{ color: "#999999" }}>{`(${infoSource?.userId || "--"
                          })`}</Text>
                      </View>
                    </View>
                  );
                } else {
                  let key = item.key;
                  console.log(key)
                  console.log(infoSource[`${key}`])
                  if (key == "beSignIn") {
                    return (
                      <View className="custom_row" key={key}>
                        <View className="left">{item?.title || "--"}</View>
                        <View className="right">{infoSource[`${key}`] == 0 ? "无需签到" : "需要签到"}</View>
                      </View>
                    )
                  } else if (key == "date") {
                    return (
                      <View className="custom_row" key={key}>
                        <View className="left">{item?.title || "--"}</View>
                        <View className="right">{infoSource.scheduleDate + "  " + infoSource.startTime + "~" + infoSource.endTime || "--"}</View>
                      </View>
                    );
                  } else {
                    return (
                      <View className="custom_row" key={key}>
                        <View className="left">{item?.title || "--"}</View>
                        <View className="right">{infoSource[`${key}`] || "--"}</View>
                      </View>
                    );
                  }
                }
              }
            })}
        </View>
        <View className="custom_footer">
          {Array.isArray(optionList) &&
            optionList.map((item, index) => {
              return (
                <LgButton
                  type={item.key === "wait" ? "D" : "B"}
                  key={index}
                  color={
                    item.key === "wait"
                      ? ""
                      : item.key === "confirm"
                        ? "open"
                        : "close"
                  }
                  className={`btn ${item.key}`}
                  onClick={() => {
                    item.callback &&
                      typeof item.callback === "function" &&
                      item.callback(item.state, infoSource, todoInfo);
                  }}
                >
                  {item.text}
                </LgButton>
              );
            })}
        </View>
      </View>
    );
  }, [customPopupParams]);

  function handleTodoUpdate(todoInfo) {
    HttpPut({
      url: "/api/todo/manage/update/status",
      data: {
        userId: userInfo.UserID,
        schoolId: userInfo.SchoolID,
        todoMsgId: todoInfo.todoMsgId,
        status: 1,
      },
    }).then(() => {
      setIsOpen3(false);
      getTodoList();
      Taro.showToast({
        title: "操作成功",
      });
    });
  }

  function handleActive(state, extraData, todoInfo) {
    // console.log(state,extraData)
    HttpPost({
      url: mainServer + "/SysMgr/Setting/Holiday/SetActivityUserStatus",
      data: {
        appid: "210",
        access_token: md5("210").split("").reverse().join(""),
        activityID: extraData.ActivityID,
        userID: userInfo.UserID,
        status: state,
      },
      header: {
        Authorization: "X-Token=" + Utils.getNowToken(),
      },
    }).then(() => {
      if (state == 1 || state == 2) {
        handleTodoUpdate(todoInfo);
      } else {
        setIsOpen3(false);
        getTodoList();
        Taro.showToast({
          title: "操作成功",
        });
      }
    });
  }

  const showMeActive = (data) => {
    console.log(data)
    if (data.status === "1") {
      return;
    }
    HttpGet({
      url: mainServer + "edu-office-platform/api/schedule/info/detail",
      data: {
        scheduleId: data.msgId,
        userId: data.userId,
        eduId: userInfo.SchoolID,
        userType: data.userType,
      },
      // header: {
      //   Authorization: "X-Token=" + Utils.getNowToken(),
      // },
    }).then((result) => {
      console.log(result)
      let activityInfo = result.data;
      let activeName = activityInfo.scheduleTitle;
      let title = data.title;
      let attrList = [
        title,
        activeName,
        { key: "userName", title: "发起人：" },
        { key: "date", title: "会议时间：" },
        { key: "scheduleLocation", title: "会议地点：" },
        { key: "scheduleContent", title: "日程描述：" },
        { key: "beSignIn", title: "会议签到：" },
      ];
      let optionList = [
        { key: "wait", text: "待定", state: "3", callback: handleActive },
        {
          key: "confirm",
          text: "确认参加",
          state: "1",
          callback: handleActive,
        },
        { key: "refuse", text: "拒绝参加", state: "2", callback: handleActive },

      ];

      setCustomPopupParams({
        attrList,
        infoSource: activityInfo,
        optionList,
        todoInfo: data,
      });
      setIsOpen3(true);
    });
  };

  // 点击事件
  const toLink = (item) => {
    console.log(item)
    if (Utils.getSystemInfo() === "h5") {
      //app环境
      if (item.pcLinkType == 1 && item.appLink) {
        Taro.getSysWeb({ sysId: item.sysId }, "web", function (res) {
          let url =
            res +
            item.appLink
              .replace("[token]", getToken())
              .replace(
                "[IdentityCode]",
                storage.get("lg_ic") || Utils.getQueryVariable("lg_ic")
              )
              .replace(
                "[identityCode]",
                storage.get("lg_ic") || Utils.getQueryVariable("lg_ic")
              );
          window.open(url, "_self");
        });
      } else if (item.pcLinkType == 3 && item.appLink) {
        window.open(item.appLink, "_self");
      } else if (item.pcLinkType == 4) {
        if (item.status === "2") {
          Taro.showToast({
            title: "已逾期",
            icon: "none",
          });
          return;
        }
        if (item.templateId === "20002") {
          showMeSchedule(item);
        } else if (item.templateId === "26408") {
          showMeAssignment(item);
        } else if (item.templateId === "26402") {
          showMeActive(item);
        }
      } else {
        dispatch({
          type: "SHOW_TOAST",
          data: "block",
        });
      }
    } else {
      if (item.pcLinkType == 1 && item.appletsLink) {
        if (item.appletsLink.includes("wxLogin")) {
          //存在小程序跳转非H5嵌入
          let paramsArr = item.appletsLink.split("#");
          let appid = paramsArr[0];
          let path = paramsArr[1];

          for (let i = 2; i < paramsArr.length; i++) {
            //若传入的链接包含多个# 则将第二个#连接的参数作为path
            path += "#" + paramsArr[i];
          }

          jumpWeapp(appid, path);
        } else {
          Taro.getSysWeb({ sysId: item.sysId }, "web", function (data) {
            let url =
              data +
              item.appletsLink
                .replace("[token]", getNowToken())
                .replace("[identityCode]", lg_ic)
                .replace("[IdentityCode]", lg_ic);
            url = useTransformUrl(url, {
              env: "weapp",
              schoolId: userInfo.SchoolID,
            });
            window.open(proxy.transmitUrlToVisit(url), "_self");
          });
        }
      } else if (item.pcLinkType == 3 && item.appletsLink) {
        window.open(item.appletsLink, "_self");
      } else if (item.pcLinkType == 4) {
        if (item.status === "2") {
          Taro.showToast({
            title: "已逾期",
            icon: "none",
          });
          return;
        }
        if (item.templateId === "20002") {
          showMeSchedule(item);
        } else if (item.templateId === "26003") {
          showMeAssignment(item);
        } else if (item.templateId === "26402") {
          showMeActive(item);
        }
      } else {
        dispatch({
          type: "SHOW_TOAST",
          data: "block",
        });
      }
    }
  };

  // 创建日程
  const createSchedule = () => {
    HttpPost({
      url: officeAddr + "/api/schedule/created/save",
      data: {
        userId: userInfo.UserID,
        userType: userInfo.UserType,
        userName: userInfo.UserName,
        schoolId: userInfo.SchoolID,
        scheduleDate: infoObj.scheduleDate,
        // "scheduleEndDate": infoObj?.scheduleEndDate || infoObj.scheduleDate,
        startTime: infoObj.startTime,
        endTime: infoObj.endTime,
        beAllDay: infoObj?.beAllDay || 0,
        scheduleTitle: infoObj?.scheduleTitle,
        scheduleContent: infoObj.scheduleContent,
        scheduleLocation: infoObj.scheduleLocation,
        remindFlag: 1,
        remindTime: infoObj?.remindTime || 30,
        remindRealTime: `${infoObj.scheduleDate} ${infoObj.startTime}:00`,
        repeatTime: 0,
        repeatTimeList: infoObj?.repeatTimeList || [0],
        termStartDate: termInfo.termStartDate,
        termEndDate: termInfo.termEndDate,
        beExternal: 1,
        meetingScheduleId: infoObj.scheduleId,
        beMeeting: 1,
        scheduleMemberBoList: infoObj.scheduleMemberBoList,
      },
    }).then(() => {
      Taro.showToast({
        title: "操作成功",
      });
    });
  };

  // 点击日程弹出框点击事件
  const handleSchedule = async (State) => {
    if (State == 0) {
      return;
    }
    HttpPost({
      url: officeAddr + "/api/schedule/member/update/attend",
      data: {
        userId: userInfo.UserID,
        scheduleId: infoObj.scheduleId,
        attendFlag: State,
        schoolId: userInfo.SchoolID,
      },
    });

    if (State == 2) {
      if (userInfo.UserID === infoObj.userId) {
        //日程发起人是自己，不再重复新建
        return;
      }
      createSchedule();
    }

    if (State == 2 || State == 3) {
      HttpPut({
        url: "/api/todo/manage/update/status",
        data: {
          userId: userInfo.UserID,
          schoolId: userInfo.SchoolID,
          todoMsgId: infoObj.todoMsgId,
          status: 1,
        },
      }).then(() => {
        getTodoList(1);
        if (State === 3) {
          Taro.showToast({
            title: "操作成功",
          });
        }
      });
    }

    setIsOpen(false);
  };

  const handleRefuse = () => {
    if (!refuseReason) {
      Taro.showToast({
        title: "原因不能为空",
        icon: "none",
      });
      return;
    }
    HttpPut({
      url: mainServer + "edu-office-platform/api/task/user/accept_refuse",
      data: {
        userId: userInfo.UserID,
        userName: userInfo.UserName,
        taskId: assignmentObj.taskId,
        progress: 3,
        refuseRemark: refuseReason,
        pushMsg: isNoticePublisher,
      },
    }).then((res) => {
      setShowReasonBox(false);
      HttpPut({
        url: "/api/todo/manage/update/status",
        data: {
          userId: userInfo.UserID,
          schoolId: userInfo.SchoolID,
          todoMsgId: currentTodo.todoMsgId,
          status: 1,
        },
      }).then(() => {
        getTodoList(1);
        setIsOpen2(false);
        Taro.showToast({
          title: "操作成功",
        });
      });
    });
  };

  // 点击任务 弹出框点击事件
  const handleSchedule2 = (state) => {
    // console.log(state)
    if (state === 0) {
      setIsOpen2(false);
      return;
    } else if (state === 1) {
      HttpPut({
        url: mainServer + "edu-office-platform/api/task/user/accept_refuse",
        data: {
          userId: userInfo.UserID,
          userName: userInfo.UserName,
          taskId: assignmentObj.taskId,
          progress: 1,
        },
      }).then(() => {
        setIsOpen2(false);
        HttpPut({
          url: "/api/todo/manage/update/status",
          data: {
            userId: userInfo.UserID,
            schoolId: userInfo.SchoolID,
            todoMsgId: currentTodo.todoMsgId,
            status: 1,
          },
        }).then(() => {
          getTodoList(1);
          Taro.showToast({
            title: "操作成功",
          });
        });
      });
    } else if (state === 3) {
      setShowReasonBox(true);
    }
  };

  // 状态选择
  const handleStatus = (data) => {
    setCurrentStatus(data.key);
  };

  //类型选择
  const handleType = (data) => {
    setCurrentType(data.msgSourceId);
  };

  // 搜索变化
  const searchHandle = _.debounce((value) => {
    setKeyword(value.trim());
  }, 500);

  // 无限刷新
  const onPull = () => {
    if (totalPage > pullCount) {
      setPullCount(pullCount + 1);
      getTodoList(pullCount + 1);
    } else {
      Taro.showToast({
        title: "到底啦",
        icon: "none",
      });
    }
  };
  // 下拉刷新
  const onDown = () => {
    getTodoList();
    setTimeout(() => {
      Taro.showToast({
        title: "刷新成功",
      });
    }, 500);
  };

  const show = () => {
    setIsOpen(false);
    handleSchedule(0);
  };

  useEffect(() => {
    getTodoList();
  }, [currentStatus, currentType, keyword]);

  useEffect(() => {
    getBasicInfo();
  }, []);

  return (
    <View className="todo_container">
      <View className="todo_option">
        <View>
          <LgSelepicker
            type="B"
            id="sele1"
            className="left"
            dataList={statusList}
            changeSele={handleStatus}
            attr="name"
          />
          <LgSelepicker
            type="B"
            id="sele2"
            className="left"
            dataList={typeList}
            changeSele={handleType}
            attr="msgSourceName"
          />{" "}
        </View>
        {isSearch ? (
          <View className="my_ipt animate__animated animate__slideInRight animate__faster">
            <LgSearch
              value={keyword}
              onConfirm={(value: string) => setKeyword(value.trim())}
              placeholder="请输入..."
              onInput={searchHandle}
            />
          </View>
        ) : (
          <View className="my_search_icon" onClick={() => setIsSearch(true)}>
            {" "}
          </View>
        )}
      </View>
      <LgRefreshPage
        LgRefreshPage
        className="index"
        onPull={onPull}
        onDown={onDown}
        downText={["下拉刷新", "释放刷新"]}
        pullText={["上拉加载更多", "释放加载更多"]}
      >
        {todoList.length > 0 ? (
          todoList.map((todo, index) => {
            if (getShowThisMsg(todo)) {
              return (
                <Card
                  type="A"
                  key={index}
                  title={todo.msgSourceName}
                  publisher={todo.userName}
                  content={todo.msgPushContent}
                  startTime={recentDateStr(todo.msgPushTime)}
                  endTime={todo.msgPushExpire}
                  status={todo.status}
                  toDetail={() => {
                    toLink(todo);
                  }}
                />
              );
            }
          })
        ) : !loadVisible ? (
          <Empty text={'待办事项'} />
        ) : (
          <Loading isOpened={true} />
        )}
      </LgRefreshPage>
      <Popup
        visible={isOpen3}
        onMaskClick={() => {
          setIsOpen3(false);
        }}
        showCloseButton={true}
        onClose={() => {
          setIsOpen3(false);
        }}
        bodyStyle={{
          borderTopLeftRadius: "12px",
          borderTopRightRadius: "12px",
          minHeight: "40vh",
        }}
      >
        {customPopup}
      </Popup>
      <LgPopLayer
        isOpen={isOpen}
        confirm={() => { }}
        showLayer={show}
        position="bottom"
        title={"日程邀请"}
        showClose
      >
        <View className="metting_box">
          <View className="title"> {infoObj.scheduleTitle} </View>
          <View className="row">
            <View className="meeting_left"> 发起人: </View>
            <View className="meeting_right">
              <Text>{infoObj?.userName || "--"}</Text>
              <Text style={{ color: "#999999" }}>
                {" "}
                {`(${infoObj?.userId || "--"})`}
              </Text>
            </View>
          </View>
          <View className="row">
            <View className="meeting_left"> 会议时间: </View>
            <View className="meeting_right">
              {`${infoObj?.scheduleDate} ${infoObj.startTime}~${infoObj.endTime}`}
            </View>
          </View>
          <View className="row">
            <View className="meeting_left"> 会议地点: </View>
            <View className="meeting_right">
              {infoObj?.scheduleLocation || "--"}
            </View>
          </View>
          <View className="row">
            <View className="meeting_left"> 日程描述: </View>
            <View className="meeting_right">
              {infoObj?.scheduleContent || "--"}
            </View>
          </View>
        </View>
        <View className="footer_operation">
          <LgButton type="D" className="btn" onClick={() => setIsOpen(false)}>
            {" "}
            待定{" "}
          </LgButton>
          <LgButton
            type="B"
            className="btn btn2"
            color="open"
            onClick={() => {
              handleSchedule(2);
            }}
          >
            {" "}
            确认参会{" "}
          </LgButton>
          <LgButton
            type="B"
            className="btn"
            color="close"
            onClick={() => {
              handleSchedule(3);
            }}
          >
            {" "}
            拒绝参会{" "}
          </LgButton>
        </View>
      </LgPopLayer>
      <LgPopLayer
        isOpen={isOpen2}
        confirm={() => { }}
        showLayer={() => setIsOpen2(false)}
        position="bottom"
        title={"活动管理"}
        showClose
      >
        <View className="metting_box">
          <View className="title"> {assignmentObj.title} </View>
          <View className="row">
            <View className="meeting_left"> 发起人: </View>
            <View className="meeting_right">
              <Text>{assignmentObj?.userName || "--"}</Text>
              <Text style={{ color: "#999999" }}>
                {" "}
                {`(${assignmentObj.userId})`}
              </Text>
            </View>
          </View>
          <View className="row">
            <View className="meeting_left"> 时限: </View>
            <View className="meeting_right time_cutdown">
              {`${assignmentObj.startTime?.substring(
                0,
                4
              )}-${assignmentObj.startTime?.substring(
                5,
                16
              )}~${assignmentObj.endTime?.substring(5, 16)}`}
            </View>
          </View>
          <View className="row">
            <View className="meeting_left"> 任务说明: </View>
            <View className="meeting_right">
              {assignmentObj?.remark || "--"}
            </View>
          </View>
        </View>
        <View className="footer_operation">
          <LgButton
            type="D"
            className="btn"
            onClick={() => {
              handleSchedule2(0);
            }}
          >
            {" "}
            暂不响应{" "}
          </LgButton>
          <LgButton
            type="B"
            className="btn btn2"
            color="open"
            onClick={() => {
              handleSchedule2(1);
            }}
          >
            {" "}
            接受任务{" "}
          </LgButton>
          <LgButton
            type="B"
            className="btn"
            color="close"
            onClick={() => {
              handleSchedule2(3);
            }}
          >
            {" "}
            拒绝任务{" "}
          </LgButton>
        </View>
      </LgPopLayer>
      <View
        className="reason_box"
        style={{ display: showReasonBox ? "" : "none" }}
      >
        <View className="reason_card">
          <View className="title">任务拒绝原因</View>
          <TextArea
            placeholder="在此输入任务拒绝的原因..."
            value={refuseReason}
            maxLength={80}
            style={{
              marginBottom: "15px",
              "--font-size": "12px",
            }}
            rows={5}
            onChange={(val) => {
              setRefuseReason(val);
            }}
          />
          <View className="option">
            <LgCheckbox
              type="B"
              default={1}
              onClick={(value) => {
                setIsNoticePublisher(value);
              }}
            />
            <View className="text">
              给发布者
              <Text style={{ color: "#ff6600" }}>{`(${assignmentObj?.userName || "--"
                })`}</Text>
              发送拒绝原因的消息提醒
            </View>
          </View>
          <View className="reason_footer">
            <LgButton type="A" className="btn" onClick={handleRefuse}>
              确认
            </LgButton>
            <LgButton
              type="C"
              className="btn"
              onClick={() => {
                setShowReasonBox(false);
                setRefuseReason("");
                setIsNoticePublisher(1);
              }}
            >
              取消
            </LgButton>
          </View>
        </View>
      </View>
    </View>
  );
}

const mainProps = ({ commonData }) => {
  return {
    userInfo: commonData.userInfo,
    env: commonData.env,
    baseUrl: commonData.baseUrl,
    mainServer: commonData.mainServer,
    lg_ic: commonData.lg_ic,
    officeAddr: commonData.officeAddr,
    termInfo: commonData.termInfo,
    isEdu: commonData.isEdu,
    noticeAddr: commonData.noticeAddr,
  };
};

export default connect(mainProps)(App);
